package com.mrgood.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;
import java.util.Map;

@Component
public class FeignConfiguration {
    @Bean
    public RequestInterceptor headerInterceptor() {
        return requestTemplate -> {
            Map<String, Collection<String>> tracingHeaders = TracingInterceptor.headerThreadLocal.get();
            if (null != tracingHeaders) {
                requestTemplate.headers(tracingHeaders);
            }
        };
    }
}
